home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc International / Recipes / TSMTE Support < prev   
Encoding:
Text File  |  1996-11-14  |  3.8 KB  |  98 lines  |  [TEXT/ttxt]

  1. TSMTE Support
  2. by The OpenDoc™ Design Team
  3. February 19, 1995
  4.  
  5.  
  6. © 1993-1996  Apple Computer, Inc. All Rights Reserved.
  7. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  8. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  9.  
  10.  
  11. Introduction
  12.  
  13. OpenDoc supports the Text Services Manager (TSM), and, in particular inline text input.  OpenDoc does nothing special to support the TSMTE extension.  So you have to do some additional work as for a current QuickDraw application which is using TextEdit with the TSMTE extension.  The extension is named "Inline Support" in the English system with the Japanese Language Kit or  "ÉCÉìÉâÉCÉìí«â¡ã@î\" in the Japanese system.  It provides you the inline input in TextEdit easily.
  14.  
  15.  
  16. What's TSMTE?
  17.  
  18. TSMTE is an extension to the Text Services Manager that does the second part of the work for you if you use TextEdit.  It provides Apple event handlers that handle all interactions between an input method and TextEdit.  The handlers are kept in the system heap, so they are shared between all applications.  TSMTE can reduce the effort needed to implement inline input to a day or two.   (See Technical Notes TE27 for the details)
  19.  
  20.  
  21. General support
  22.  
  23. OpenDoc calls InitTSMAwareApp, CloseTSMAwareApp, TSMEvent, TSMMenuSelect, and SetTSMCursor at the appropriate times. Parts do not need to call any of these.
  24.  
  25.  
  26. Inline input support
  27.  
  28. First,  you need to specify the definition to include the TSMTE header file in your source code as follows.  The header file is contained in the Developer CD.
  29.  
  30.     #ifdef __TSMTE__   
  31.     #include "TSMTE.h"
  32.     #endif
  33.  
  34. Parts wishing to use the TSMTE extension must check for its existence themselves.
  35.  
  36.     long           result;
  37.     
  38.     if (Gestalt(kTSMTESignature, &result) == noErr    &&
  39.         (result & (1 << gestaltTSMTE)) != 0)
  40.             // You can use TSMTE. Set the TSMTE available flag to kODTrue.
  41.     else
  42.             // You cannot use TSMTE. Set the TSMTE available flag to kODFalse.
  43.  
  44. After creating a text edit record by calling TENew or TEStyleNew, the part has to create a TSM document and enable the inline input by calling UseInputWindow API.
  45.  
  46.     OSErr          err;
  47.     OSType         interfaceTypes[]= {kTSMTEInterfaceType};
  48.     TSMDocumentID  tsmDocID;
  49.     TSMTERecHandle tsmteH;
  50.     TEHandle       theTE;
  51.  
  52.     theTE = TEStyleNew(...);
  53.     if (the TSMTE available flag is kODTrue)
  54.     {
  55.         err = NewTSMDocument(1, interfaceTypes, &tsmDocID, (long)&tsmteH);
  56.         if (err == noErr)
  57.         {
  58.             (*tsmteH)->textH          = theTE; // A handle to the TERec to be inline input.
  59.             (*tsmteH)->preUpdateProc  = kODNULL;
  60.             (*tsmteH)->postUpdateProc = kODNULL;
  61.             (*tsmteH)->updateFlag     = kTSMTEAutoScroll;
  62.             (*tsmteH)->refCon         = kODNULL;
  63.  
  64.             UseInputWindow(kODNULL, kODFalse);
  65.         }
  66.     }
  67.  
  68. When you activate or deactivate the text edit record, you have to call the API for activating/deactivating the TSM document at the same time.
  69.  
  70.     // Activate the specified text edit record
  71.     if (the TSMTE available flag is kODTrue)
  72.     {
  73.         ActivateTSMDocument(tsmDocID);
  74.     }
  75.     TEActivate(theTE);
  76.  
  77.     // Deactivate the specified text edit record
  78.     if (the TSMTE available flag is kODTrue)
  79.     {
  80.         DeactivateTSMDocument(tsmDocID);
  81.     }
  82.     TEDeactivate(theTE);
  83.  
  84. Finally,  when the text edit record is removed and released by calling TEDispose, you have to call the API for TSM at the same time.
  85.  
  86.     // Dispose the specified text edit record
  87.     if (the TSMTE available flag is kODTrue)
  88.     {
  89.         DeleteTSMDocument(tsmDocID);
  90.     }
  91.     TEDispose(theTE);
  92.  
  93.  
  94.  
  95. Additional Info
  96.  
  97. See also TSM support recipe in the folder Documentation:Tech Notes & Articles:Recipes:International.
  98. You can also find the technical notes regarding TSMTE. The TSMTE extension, header files, and sample code are available on the latest Developer CD.